
extern "C" {
    pub type _IO_wide_data;
    pub type _IO_codecvt;
    pub type _IO_marker;
    fn memmove(_: *mut (), _: *const (), _: u64) -> *mut ();
    fn strcpy(_: *mut i8, _: *const i8) -> *mut i8;
    fn strcmp(_: *const i8, _: *const i8) -> i32;
    fn strlen(_: *const i8) -> u64;
    fn malloc(_: u64) -> *mut ();
    fn calloc(_: u64, _: u64) -> *mut ();
    fn free(_: *mut ());
    static mut stderr: *mut FILE;
    fn sscanf(_: *const i8, _: *const i8, _: ...) -> i32;
    fn printf(_: *const i8, _: ...) -> i32;
    fn fprintf(_: *mut FILE, _: *const i8, _: ...) -> i32;
}
pub type size_t = u64;
pub type __off_t = i64;
pub type __off64_t = i64;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _IO_FILE {
    pub _flags: i32,
    pub _IO_read_ptr: *mut i8,
    pub _IO_read_end: *mut i8,
    pub _IO_read_base: *mut i8,
    pub _IO_write_base: *mut i8,
    pub _IO_write_ptr: *mut i8,
    pub _IO_write_end: *mut i8,
    pub _IO_buf_base: *mut i8,
    pub _IO_buf_end: *mut i8,
    pub _IO_save_base: *mut i8,
    pub _IO_backup_base: *mut i8,
    pub _IO_save_end: *mut i8,
    pub _markers: *mut _IO_marker,
    pub _chain: *mut _IO_FILE,
    pub _fileno: i32,
    pub _flags2: i32,
    pub _old_offset: __off_t,
    pub _cur_column: u16,
    pub _vtable_offset: i8,
    pub _shortbuf: [i8; 1],
    pub _lock: *mut (),
    pub _offset: __off64_t,
    pub _codecvt: *mut _IO_codecvt,
    pub _wide_data: *mut _IO_wide_data,
    pub _freeres_list: *mut _IO_FILE,
    pub _freeres_buf: *mut (),
    pub __pad5: size_t,
    pub _mode: i32,
    pub _unused2: [i8; 20],
}
pub type _IO_lock_t = ();
pub type FILE = _IO_FILE;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct url_key_value {
    pub key: *const i8,
    pub value: *const i8,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct url_data {
    pub whole_url: *mut i8,
    pub protocol: *const i8,
    pub userinfo: *const i8,
    pub host: *const i8,
    pub port: *const i8,
    pub path: *const i8,
    pub query: *const url_key_value,
    pub fragment: *const i8,
}
pub type url_data_t = url_data;
pub type Category = u32;
pub const IPv6Char: Category = 256;
pub const Userinfo: Category = 128;
pub const Fragment: Category = 64;
pub const Query: Category = 64;
pub const HexDigit: Category = 32;
pub const PCharSlash: Category = 16;
pub const SubDelim: Category = 8;
pub const GenDelim: Category = 4;
pub const Unreserved: Category = 2;
pub const Scheme: Category = 1;
#[inline]
extern "C" fn url_get_hash(mut url: *const i8) -> *mut i8 {
    return url_get_fragment(url);
}
#[inline]
extern "C" fn url_get_protocol(mut url: *const i8) -> *mut i8 {
    return url_get_scheme(url);
}
static mut char_cat: [u16; 256] = [ 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16,
    0xd8 as i32 as u16, 0 as u16,
    0x4 as i32 as u16,
    0xd8 as i32 as u16,
    0xd0 as i32 as u16,
    0xd8 as i32 as u16,
    0xd8 as i32 as u16,
    0xd8 as i32 as u16,
    0xd8 as i32 as u16,
    0xd8 as i32 as u16,
    0xd9 as i32 as u16,
    0xd8 as i32 as u16,
    0xd3 as i32 as u16,
    0xd3 as i32 as u16,
    0x54 as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1d4 as i32 as u16,
    0xd8 as i32 as u16, 0 as u16,
    0xd8 as i32 as u16, 0 as u16,
    0x44 as i32 as u16,
    0x54 as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0x4 as i32 as u16, 0 as u16,
    0x4 as i32 as u16, 0 as u16,
    0xd2 as i32 as u16, 0 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0x1ff as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16,
    0xdf as i32 as u16, 0 as u16, 0 as u16, 0 as u16,
    0xd2 as i32 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16, 0 as u16,
];
static mut URL_SCHEMES: [*const i8; 177] = [
    b"aaa\0" as *const u8 as *const i8,
    b"aaas\0" as *const u8 as *const i8,
    b"about\0" as *const u8 as *const i8,
    b"acap\0" as *const u8 as *const i8,
    b"acct\0" as *const u8 as *const i8,
    b"adiumxtra\0" as *const u8 as *const i8,
    b"afp\0" as *const u8 as *const i8,
    b"afs\0" as *const u8 as *const i8,
    b"aim\0" as *const u8 as *const i8,
    b"apt\0" as *const u8 as *const i8,
    b"attachment\0" as *const u8 as *const i8,
    b"aw\0" as *const u8 as *const i8,
    b"beshare\0" as *const u8 as *const i8,
    b"bitcoin\0" as *const u8 as *const i8,
    b"bolo\0" as *const u8 as *const i8,
    b"callto\0" as *const u8 as *const i8,
    b"cap\0" as *const u8 as *const i8,
    b"chrome\0" as *const u8 as *const i8,
    b"crome-extension\0" as *const u8 as *const i8,
    b"com-evenbrite-attendee\0" as *const u8 as *const i8,
    b"cid\0" as *const u8 as *const i8,
    b"coap\0" as *const u8 as *const i8,
    b"coaps\0" as *const u8 as *const i8,
    b"content\0" as *const u8 as *const i8,
    b"crid\0" as *const u8 as *const i8,
    b"cvs\0" as *const u8 as *const i8,
    b"data\0" as *const u8 as *const i8,
    b"dav\0" as *const u8 as *const i8,
    b"dict\0" as *const u8 as *const i8,
    b"lna-playsingle\0" as *const u8 as *const i8,
    b"dln-playcontainer\0" as *const u8 as *const i8,
    b"dns\0" as *const u8 as *const i8,
    b"dtn\0" as *const u8 as *const i8,
    b"dvb\0" as *const u8 as *const i8,
    b"ed2k\0" as *const u8 as *const i8,
    b"facetime\0" as *const u8 as *const i8,
    b"fax\0" as *const u8 as *const i8,
    b"feed\0" as *const u8 as *const i8,
    b"file\0" as *const u8 as *const i8,
    b"finger\0" as *const u8 as *const i8,
    b"fish\0" as *const u8 as *const i8,
    b"ftp\0" as *const u8 as *const i8,
    b"geo\0" as *const u8 as *const i8,
    b"gg\0" as *const u8 as *const i8,
    b"git\0" as *const u8 as *const i8,
    b"gizmoproject\0" as *const u8 as *const i8,
    b"go\0" as *const u8 as *const i8,
    b"gopher\0" as *const u8 as *const i8,
    b"gtalk\0" as *const u8 as *const i8,
    b"h323\0" as *const u8 as *const i8,
    b"hcp\0" as *const u8 as *const i8,
    b"http\0" as *const u8 as *const i8,
    b"https\0" as *const u8 as *const i8,
    b"iax\0" as *const u8 as *const i8,
    b"icap\0" as *const u8 as *const i8,
    b"icon\0" as *const u8 as *const i8,
    b"im\0" as *const u8 as *const i8,
    b"imap\0" as *const u8 as *const i8,
    b"info\0" as *const u8 as *const i8,
    b"ipn\0" as *const u8 as *const i8,
    b"ipp\0" as *const u8 as *const i8,
    b"irc\0" as *const u8 as *const i8,
    b"irc6\0" as *const u8 as *const i8,
    b"ircs\0" as *const u8 as *const i8,
    b"iris\0" as *const u8 as *const i8,
    b"iris.beep\0" as *const u8 as *const i8,
    b"iris.xpc\0" as *const u8 as *const i8,
    b"iris.xpcs\0" as *const u8 as *const i8,
    b"iris.lws\0" as *const u8 as *const i8,
    b"itms\0" as *const u8 as *const i8,
    b"jabber\0" as *const u8 as *const i8,
    b"jar\0" as *const u8 as *const i8,
    b"jms\0" as *const u8 as *const i8,
    b"keyparc\0" as *const u8 as *const i8,
    b"lastfm\0" as *const u8 as *const i8,
    b"ldap\0" as *const u8 as *const i8,
    b"ldaps\0" as *const u8 as *const i8,
    b"magnet\0" as *const u8 as *const i8,
    b"mailserver\0" as *const u8 as *const i8,
    b"mailto\0" as *const u8 as *const i8,
    b"maps\0" as *const u8 as *const i8,
    b"market\0" as *const u8 as *const i8,
    b"message\0" as *const u8 as *const i8,
    b"mid\0" as *const u8 as *const i8,
    b"mms\0" as *const u8 as *const i8,
    b"modem\0" as *const u8 as *const i8,
    b"ms-help\0" as *const u8 as *const i8,
    b"mssettings-power\0" as *const u8 as *const i8,
    b"msnim\0" as *const u8 as *const i8,
    b"msrp\0" as *const u8 as *const i8,
    b"msrps\0" as *const u8 as *const i8,
    b"mtqp\0" as *const u8 as *const i8,
    b"mumble\0" as *const u8 as *const i8,
    b"mupdate\0" as *const u8 as *const i8,
    b"mvn\0" as *const u8 as *const i8,
    b"news\0" as *const u8 as *const i8,
    b"nfs\0" as *const u8 as *const i8,
    b"ni\0" as *const u8 as *const i8,
    b"nih\0" as *const u8 as *const i8,
    b"nntp\0" as *const u8 as *const i8,
    b"notes\0" as *const u8 as *const i8,
    b"oid\0" as *const u8 as *const i8,
    b"paquelocktoken\0" as *const u8 as *const i8,
    b"pack\0" as *const u8 as *const i8,
    b"palm\0" as *const u8 as *const i8,
    b"paparazzi\0" as *const u8 as *const i8,
    b"pkcs11\0" as *const u8 as *const i8,
    b"platform\0" as *const u8 as *const i8,
    b"pop\0" as *const u8 as *const i8,
    b"pres\0" as *const u8 as *const i8,
    b"prospero\0" as *const u8 as *const i8,
    b"proxy\0" as *const u8 as *const i8,
    b"psyc\0" as *const u8 as *const i8,
    b"query\0" as *const u8 as *const i8,
    b"reload\0" as *const u8 as *const i8,
    b"res\0" as *const u8 as *const i8,
    b"resource\0" as *const u8 as *const i8,
    b"rmi\0" as *const u8 as *const i8,
    b"rsync\0" as *const u8 as *const i8,
    b"rtmp\0" as *const u8 as *const i8,
    b"rtsp\0" as *const u8 as *const i8,
    b"secondlife\0" as *const u8 as *const i8,
    b"service\0" as *const u8 as *const i8,
    b"session\0" as *const u8 as *const i8,
    b"sftp\0" as *const u8 as *const i8,
    b"sgn\0" as *const u8 as *const i8,
    b"shttp\0" as *const u8 as *const i8,
    b"sieve\0" as *const u8 as *const i8,
    b"sip\0" as *const u8 as *const i8,
    b"sips\0" as *const u8 as *const i8,
    b"skype\0" as *const u8 as *const i8,
    b"smb\0" as *const u8 as *const i8,
    b"sms\0" as *const u8 as *const i8,
    b"snews\0" as *const u8 as *const i8,
    b"snmp\0" as *const u8 as *const i8,
    b"soap.beep\0" as *const u8 as *const i8,
    b"soap.beeps\0" as *const u8 as *const i8,
    b"soldat\0" as *const u8 as *const i8,
    b"spotify\0" as *const u8 as *const i8,
    b"ssh\0" as *const u8 as *const i8,
    b"steam\0" as *const u8 as *const i8,
    b"svn\0" as *const u8 as *const i8,
    b"tag\0" as *const u8 as *const i8,
    b"teamspeak\0" as *const u8 as *const i8,
    b"tel\0" as *const u8 as *const i8,
    b"telnet\0" as *const u8 as *const i8,
    b"tftp\0" as *const u8 as *const i8,
    b"things\0" as *const u8 as *const i8,
    b"thismessage\0" as *const u8 as *const i8,
    b"tn3270\0" as *const u8 as *const i8,
    b"tip\0" as *const u8 as *const i8,
    b"tv\0" as *const u8 as *const i8,
    b"udp\0" as *const u8 as *const i8,
    b"unreal\0" as *const u8 as *const i8,
    b"urn\0" as *const u8 as *const i8,
    b"ut2004\0" as *const u8 as *const i8,
    b"vemmi\0" as *const u8 as *const i8,
    b"ventrilo\0" as *const u8 as *const i8,
    b"videotex\0" as *const u8 as *const i8,
    b"view-source\0" as *const u8 as *const i8,
    b"wais\0" as *const u8 as *const i8,
    b"webcal\0" as *const u8 as *const i8,
    b"ws\0" as *const u8 as *const i8,
    b"wss\0" as *const u8 as *const i8,
    b"wtai\0" as *const u8 as *const i8,
    b"wyciwyg\0" as *const u8 as *const i8,
    b"xcon\0" as *const u8 as *const i8,
    b"xcon-userid\0" as *const u8 as *const i8,
    b"xfire\0" as *const u8 as *const i8,
    b"xmlrpc.beep\0" as *const u8 as *const i8,
    b"xmlrpc.beeps\0" as *const u8 as *const i8,
    b"xmpp\0" as *const u8 as *const i8,
    b"xri\0" as *const u8 as *const i8,
    b"ymsgr\0" as *const u8 as *const i8,
    b"javascript\0" as *const u8 as *const i8,
    b"jdbc\0" as *const u8 as *const i8,
    b"doi\0" as *const u8 as *const i8,
];
#[no_mangle]
pub extern "C" fn strdup(mut str: *const i8) -> *mut i8 {
    let n: i32 = (unsafe { strlen(str) }).wrapping_add(1 as i32 as u64) as i32;
    let mut dup: *mut i8 = (unsafe { malloc(n as u64) }) as *mut i8;
    if !dup.is_null() {
        (unsafe { strcpy(dup, str) });
    }
    return dup;
}
extern "C" fn unhex(mut s: *const i8) -> i32 {
    if (unsafe { *s }) as i32 >= '0' as i32 && (unsafe { *s }) as i32 <= '9' as i32 {
        return (unsafe { *s }) as i32 - '0' as i32;
    }
    if (unsafe { *s }) as i32 >= 'A' as i32 && (unsafe { *s }) as i32 <= 'F' as i32 {
        return (unsafe { *s }) as i32 - 'A' as i32 + 10;
    }
    if (unsafe { *s }) as i32 >= 'a' as i32 && (unsafe { *s }) as i32 <= 'f' as i32 {
        return (unsafe { *s }) as i32 - 'a' as i32 + 10;
    }
    return -(1 as i32);
}
extern "C" fn decode_percent(mut s: *mut i8) -> *mut i8 {
    let mut in_0: *mut i8 = s;
    let mut out: *mut i8 = s;
    while (unsafe { *in_0 }) != 0 {
        if (unsafe { *in_0 }) as i32 == '%' as i32 {
            in_0 = unsafe { in_0.offset(1) };
            let high: i32 = unhex(in_0);
            if high < 0 || (unsafe { *in_0 }) as i32 == '\0' as i32 {
                return 0 as *mut i8;
            }
            in_0 = unsafe { in_0.offset(1) };
            let low: i32 = unhex(in_0);
            if low < 0 || (unsafe { *in_0 }) as i32 == '\0' as i32 {
                return std::ptr::null_mut::<i8>();
            }
            (unsafe {
                *out = (high as u32)
                    .wrapping_mul(16 as u32)
                    .wrapping_add(low as u32) as i8
            });
            out = unsafe { out.offset(1) };
            in_0 = unsafe { in_0.offset(1) };
        } else {
            let fresh0 = in_0;
            in_0 = unsafe { in_0.offset(1) };
            let fresh1 = out;
            out = unsafe { out.offset(1) };
            (unsafe { *fresh1 = *fresh0 });
        }
    }
    (unsafe { *out = '\0' as i32 as i8 });
    return s;
}
extern "C" fn scan_part(
    mut start: *mut i8,
    mut category: Category,
    mut delimiter1: i8,
    mut delimiter2: i8,
) -> *mut i8 {
    let mut p: *mut i8 = start;
    loop {
        if (unsafe { *p }) as i32 == '\0' as i32
            || (unsafe { *p }) as i32 == delimiter1 as i32
            || (unsafe { *p }) as i32 == delimiter2 as i32
        {
            return p;
        }
        if (unsafe { char_cat[*p as u8 as usize] }) as u32 & category as u32 != 0 {
            p = unsafe { p.offset(1) };
        } else {
            return std::ptr::null_mut::<i8>();
        }
    }
}
extern "C" fn scan_decimal_number(mut start: *mut i8) -> *mut i8 {
    let mut p: *mut i8 = start;
    while (unsafe { *p }) as i32 >= '0' as i32 && (unsafe { *p }) as i32 <= '9' as i32 {
        p = unsafe { p.offset(1) };
    }
    return if p != start {
        p
    } else {
        std::ptr::null_mut::<i8>()
    };
}
extern "C" fn parse_query_string(mut begin: *mut i8, mut end: *mut i8) -> *mut url_key_value {
    let mut current_block: u64;
    let mut elements: u32 = 1 as u32;
    let mut p: *const i8 = begin;
    while p != end as *const i8 {
        if (unsafe { *p }) as i32 == '&' as i32 || (unsafe { *p }) as i32 == ';' as i32 {
            elements = elements.wrapping_add(1);
        }
        p = unsafe { p.offset(1) };
    }
    let mut kv: *mut url_key_value = (unsafe {
        calloc(
            elements.wrapping_add(1 as i32 as u32) as u64,
            ::core::mem::size_of::<url_key_value>() as u64,
        )
    }) as *mut url_key_value;
    if kv.is_null() {
        return std::ptr::null_mut::<url_key_value>();
    }
    let mut p_0: *mut i8 = begin;
    let mut element: u32 = 0 as u32;
    loop {
        if !(element <= elements && p_0 < end) {
            current_block = 11584701595673473500;
            break;
        }
        let mut key: *mut i8 = p_0;
        let mut kv_end: *mut i8 = scan_part(p_0, Query, '&' as i32 as i8, ';' as i32 as i8);
        if kv_end.is_null() {
            (unsafe {
                fprintf(
                    stderr,
                    b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as *const u8 as *const i8,
                    b"url.c\0" as *const u8 as *const i8, 153,
                    p_0,
                )
            });
            current_block = 2001839956368484859;
            break;
        } else {
            (unsafe { *kv_end = '\0' as i32 as i8 });
            let mut key_end: *mut i8 = scan_part(p_0, Query, '=' as i32 as i8, '\0' as i32 as i8);
            let has_value: bool = (unsafe { *key_end }) as i32 == '=' as i32;
            (unsafe { *key_end = '\0' as i32 as i8 });
            let fresh2 = unsafe { &mut ((*kv.offset(element as isize)).key) };
            *fresh2 = decode_percent(key);
            if has_value {
                let mut value: *mut i8 = unsafe { key_end.offset(1 as i32 as isize) };
                let fresh3 = unsafe { &mut (*kv.offset(element as isize)).value };
                *fresh3 = decode_percent(value);
            } else {
                let fresh4 = unsafe { &mut (*kv.offset(element as isize)).value };
                *fresh4 = key_end;
            }
            p_0 = unsafe { kv_end.offset(1 as i32 as isize) };
            element = element.wrapping_add(1);
        }
    }
    match current_block {
        11584701595673473500 => return kv,
        _ => {
            (unsafe { free(kv as *mut ()) });
            return std::ptr::null_mut::<url_key_value>();
        }
    };
}
#[no_mangle]
pub extern "C" fn url_parse(mut url: *const i8) -> *mut url_data_t {
    let mut p_end: *const i8 = std::ptr::null::<i8>();
    let mut protocol_end: *mut i8 = std::ptr::null_mut::<i8>();
    let mut is_ssh: bool = false;
    let mut second_slash: *mut i8 = std::ptr::null_mut::<i8>();
    let mut userinfo_end: *mut i8 = std::ptr::null_mut::<i8>();
    let mut hostname_end: *mut i8 = std::ptr::null_mut::<i8>();
    let mut path_end: *mut i8 = std::ptr::null_mut::<i8>();
    let mut has_query: bool = false;
    let mut has_fragment: bool = false;
    let mut current_block: u64;
    let mut data: *mut url_data_t =
        (unsafe { calloc(1 as i32 as u64, ::core::mem::size_of::<url_data_t>() as u64) })
            as *mut url_data_t;
    if data.is_null() {
        return std::ptr::null_mut::<url_data_t>();
    }
    let mut p: *mut i8 = strdup(url);
    if p.is_null() {
        (unsafe {
            fprintf(
                stderr,
                b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as *const u8 as *const i8,
                b"url.c\0" as *const u8 as *const i8, 190,
                p,
            )
        });
    } else {
        (unsafe { (*data).whole_url = p });
        p_end = unsafe { p.offset(strlen(p) as isize) };
        protocol_end = scan_part(p, Scheme, ':' as i32 as i8, '\0' as i32 as i8);
        if protocol_end.is_null() || (unsafe { *protocol_end }) as i32 == '\0' as i32 {
            (unsafe {
                fprintf(
                    stderr,
                    b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as *const u8 as *const i8,
                    b"url.c\0" as *const u8 as *const i8, 197,
                    p,
                )
            });
        } else {
            (unsafe { *protocol_end = '\0' as i32 as i8 });
            (unsafe { (*data).protocol = p });
            is_ssh = url_is_ssh(unsafe { (*data).protocol });
            p = unsafe { protocol_end.offset(1 as i32 as isize) };
            if p >= p_end as *mut i8 || (unsafe { *p }) as i32 != '/' as i32 {
                (unsafe {
                    fprintf(
                        stderr,
                        b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as *const u8 as *const i8,
                        b"url.c\0" as *const u8 as *const i8, 205,
                        p,
                    )
                });
            } else {
                p = unsafe { p.offset(1) };
                if p >= p_end as *mut i8 || (unsafe { *p }) as i32 != '/' as i32 {
                    (unsafe {
                        fprintf(
                            stderr,
                            b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as *const u8 as *const i8,
                            b"url.c\0" as *const u8 as *const i8, 209,
                            p,
                        )
                    });
                } else {
                    second_slash = p;
                    p = unsafe { p.offset(1) };
                    if p >= p_end as *mut i8 {
                        (unsafe {
                            fprintf(
                                stderr,
                                b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as *const u8
                                    as *const i8,
                                b"url.c\0" as *const u8 as *const i8, 215,
                                p,
                            )
                        });
                    } else {
                        userinfo_end = scan_part(p, Userinfo, '@' as i32 as i8, '\0' as i32 as i8);
                        if !userinfo_end.is_null()
                            && (unsafe { *userinfo_end }) as i32 == '@' as i32
                        {
                            (unsafe { *userinfo_end = '\0' as i32 as i8 });
                            (unsafe { (*data).userinfo = p });
                            p = unsafe { userinfo_end.offset(1 as i32 as isize) };
                        }
                        if p >= p_end as *mut i8 {
                            (unsafe {
                                fprintf(
                                    stderr,
                                    b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as *const u8
                                        as *const i8,
                                    b"url.c\0" as *const u8 as *const i8, 225,
                                    p,
                                )
                            });
                        } else {
                            hostname_end = std::ptr::null_mut::<i8>();
                            if (unsafe { *p }) as i32 == '[' as i32 {
                                p = unsafe { p.offset(1) };
                                hostname_end =
                                    scan_part(p, IPv6Char, ']' as i32 as i8, '\0' as i32 as i8);
                                if hostname_end.is_null() {
                                    (unsafe {
                                        fprintf(
                                            stderr,
                                            b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0"
                                                as *const u8
                                                as *const i8,
                                            b"url.c\0" as *const u8 as *const i8, 234,
                                            p,
                                        )
                                    });
                                    current_block = 8693187068975960654;
                                } else {
                                    (unsafe { *hostname_end = '\0' as i32 as i8 });
                                    (unsafe { (*data).host = p });
                                    hostname_end = unsafe { hostname_end.offset(1) };
                                    if hostname_end < p_end as *mut i8
                                        && !is_ssh
                                        && (unsafe { *hostname_end }) as i32 == ':' as i32
                                    {
                                        let mut port_end: *mut i8 = scan_decimal_number(unsafe {
                                            hostname_end.offset(1 as i32 as isize)
                                        });
                                        if !port_end.is_null() {
                                            (unsafe {
                                                (*data).port =
                                                    hostname_end.offset(1 as i32 as isize)
                                            });
                                            p = port_end;
                                            current_block = 7252614138838059896;
                                        } else {
                                            (unsafe {
                                                fprintf(
                                                    stderr,
                                                    b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0"
                                                        as *const u8
                                                        as *const i8,
                                                    b"url.c\0" as *const u8 as *const i8, 247,
                                                    p,
                                                )
                                            });
                                            current_block = 8693187068975960654;
                                        }
                                    } else {
                                        p = hostname_end;
                                        current_block = 7252614138838059896;
                                    }
                                }
                            } else {
                                hostname_end = scan_part(
                                    p,
                                    (Unreserved as i32 | SubDelim as i32) as Category,
                                    ':' as i32 as i8,
                                    '/' as i32 as i8,
                                );
                                if hostname_end.is_null() {
                                    (unsafe {
                                        fprintf(
                                            stderr,
                                            b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0"
                                                as *const u8
                                                as *const i8,
                                            b"url.c\0" as *const u8 as *const i8, 255,
                                            p,
                                        )
                                    });
                                    current_block = 8693187068975960654;
                                } else {
                                    (unsafe { (*data).host = p });
                                    if !is_ssh && (unsafe { *hostname_end }) as i32 == ':' as i32 {
                                        (unsafe { *hostname_end = '\0' as i32 as i8 });
                                        let mut port_end_0: *mut i8 = scan_decimal_number(unsafe {
                                            hostname_end.offset(1 as i32 as isize)
                                        });
                                        if !port_end_0.is_null() {
                                            (unsafe {
                                                (*data).port =
                                                    hostname_end.offset(1 as i32 as isize)
                                            });
                                            p = port_end_0;
                                            current_block = 7252614138838059896;
                                        } else {
                                            (unsafe {
                                                fprintf(
                                                    stderr,
                                                    b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0"
                                                        as *const u8
                                                        as *const i8,
                                                    b"url.c\0" as *const u8 as *const i8, 267,
                                                    p,
                                                )
                                            });
                                            current_block = 8693187068975960654;
                                        }
                                    } else {
                                        p = hostname_end;
                                        current_block = 7252614138838059896;
                                    }
                                }
                            }
                            match current_block {
                                8693187068975960654 => {}
                                _ => {
                                    (unsafe {
                                        memmove(
                                            second_slash as *mut (),
                                            second_slash.offset(1 as i32 as isize)
                                                as *const (),
                                            p.offset_from(second_slash) as i64 as u64,
                                        )
                                    });
                                    if !(unsafe { (*data).userinfo }).is_null() {
                                        (unsafe {
                                            (*data).userinfo = ((*data).userinfo).offset(-1)
                                        });
                                    }
                                    (unsafe { (*data).host = ((*data).host).offset(-1) });
                                    if !(unsafe { (*data).port }).is_null() {
                                        (unsafe { (*data).port = ((*data).port).offset(-1) });
                                    }
                                    (unsafe {
                                        *p.offset(-(1 as i32) as isize) = '\0' as i32 as i8
                                    });
                                    if is_ssh as i32 != 0 && (unsafe { *p }) as i32 == ':' as i32 {
                                        p = unsafe { p.offset(1) };
                                    }
                                    path_end = scan_part(
                                        p,
                                        PCharSlash,
                                        '?' as i32 as i8,
                                        '#' as i32 as i8,
                                    );
                                    if path_end.is_null() {
                                        (unsafe {
                                            fprintf(
                                                stderr,
                                                b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0"
                                                    as *const u8
                                                    as *const i8,
                                                b"url.c\0" as *const u8 as *const i8, 295,
                                                p,
                                            )
                                        });
                                    } else {
                                        has_query = (unsafe { *path_end }) as i32 == '?' as i32;
                                        has_fragment = (unsafe { *path_end }) as i32 == '#' as i32;
                                        (unsafe { *path_end = '\0' as i32 as i8 });
                                        (unsafe { (*data).path = decode_percent(p) });
                                        p = unsafe { path_end.offset(1 as i32 as isize) };
                                        if has_query {
                                            let mut query_end: *mut i8 = scan_part(
                                                p,
                                                Query,
                                                '#' as i32 as i8,
                                                '\0' as i32 as i8,
                                            );
                                            if !query_end.is_null() {
                                                let has_fragment_0: bool =
                                                    (unsafe { *query_end }) as i32 == '#' as i32;
                                                (unsafe { *query_end = '\0' as i32 as i8 });
                                                (unsafe {
                                                    (*data).query = parse_query_string(p, query_end)
                                                });
                                                if has_fragment_0 {
                                                    let mut fragment_end: *mut i8 = scan_part(
                                                        unsafe {
                                                            query_end.offset(1 as i32 as isize)
                                                        },
                                                        Fragment,
                                                        '\0' as i32 as i8,
                                                        '\0' as i32 as i8,
                                                    );
                                                    if !fragment_end.is_null() {
                                                        (unsafe {
                                                            (*data).fragment = decode_percent(
                                                                query_end.offset(1 as i32 as isize),
                                                            )
                                                        });
                                                        current_block = 6406431739208918833;
                                                    } else {
                                                        (unsafe {
                                                            fprintf (stderr , b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0" as * const u8 as * const i8 , b"url.c\0" as * const u8 as * const i8 , 319 , p ,)
                                                        });
                                                        current_block = 8693187068975960654;
                                                    }
                                                } else {
                                                    current_block = 6406431739208918833;
                                                }
                                            } else {
                                                (unsafe {
                                                    fprintf(
                                                    stderr,
                                                    b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0"
                                                        as *const u8
                                                        as *const i8,
                                                    b"url.c\0" as *const u8 as *const i8, 323,
                                                    p,
                                                )
                                                });
                                                current_block = 8693187068975960654;
                                            }
                                        } else if has_fragment {
                                            let mut fragment_end_0: *mut i8 = scan_part(
                                                p,
                                                Fragment,
                                                '\0' as i32 as i8,
                                                '\0' as i32 as i8,
                                            );
                                            if !fragment_end_0.is_null() {
                                                (unsafe { (*data).fragment = decode_percent(p) });
                                                current_block = 6406431739208918833;
                                            } else {
                                                (unsafe {
                                                    fprintf(
                                                    stderr,
                                                    b"ERROR %s Line %u! p=\xC2\xAB%s\xC2\xBB\n\0"
                                                        as *const u8
                                                        as *const i8,
                                                    b"url.c\0" as *const u8 as *const i8, 332,
                                                    p,
                                                )
                                                });
                                                current_block = 8693187068975960654;
                                            }
                                        } else {
                                            current_block = 6406431739208918833;
                                        }
                                        match current_block {
                                            8693187068975960654 => {}
                                            _ => return data,
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    url_free(data);
    return std::ptr::null_mut::<url_data_t>();
}
#[no_mangle]
pub extern "C" fn url_is_protocol(mut str: *const i8) -> bool {
    let count: u32 = (::core::mem::size_of::<[*const i8; 177]>() as u64)
        .wrapping_div(::core::mem::size_of::<*const i8>() as u64) as u32;
    let mut i: u32 = 0 as u32;
    while i < count {
        if 0 == (unsafe { strcmp(URL_SCHEMES[i as usize], str) }) {
            return 1 != 0;
        }
        i = i.wrapping_add(1);
    }
    return 0 != 0;
}
#[no_mangle]
pub extern "C" fn url_is_ssh(mut str: *const i8) -> bool {
    if 0 == (unsafe { strcmp(str, b"ssh\0" as *const u8 as *const i8) })
        || 0 == (unsafe { strcmp(str, b"git\0" as *const u8 as *const i8) })
    {
        return 1 != 0;
    }
    return 0 != 0;
}
#[no_mangle]
pub extern "C" fn url_get_scheme(mut url: *const i8) -> *mut i8 {
    let mut protocol: *mut i8 = (unsafe { malloc(32 as i32 as u64) }) as *mut i8;
    if protocol.is_null() {
        return std::ptr::null_mut::<i8>();
    }
    (unsafe { sscanf(url, b"%[^://]\0" as *const u8 as *const i8, protocol) });
    if url_is_protocol(protocol) {
        return protocol;
    }
    (unsafe { free(protocol as *mut ()) });
    return std::ptr::null_mut::<i8>();
}
#[no_mangle]
pub extern "C" fn url_get_userinfo(mut url: *const i8) -> *mut i8 {
    let mut data: *mut url_data_t = url_parse(url);
    let mut out: *mut i8 = if !data.is_null() && !(unsafe { (*data).userinfo }).is_null() {
        strdup(unsafe { (*data).userinfo })
    } else {
        std::ptr::null_mut::<i8>()
    };
    url_free(data);
    return out;
}
#[no_mangle]
pub extern "C" fn url_get_hostname(mut url: *const i8) -> *mut i8 {
    let mut data: *mut url_data_t = url_parse(url);
    let mut out: *mut i8 = if !data.is_null() && !(unsafe { (*data).host }).is_null() {
        strdup(unsafe { (*data).host })
    } else {
        std::ptr::null_mut::<i8>()
    };
    url_free(data);
    return out;
}
#[no_mangle]
pub extern "C" fn url_get_host(mut url: *const i8) -> *mut i8 {
    let mut data: *mut url_data_t = url_parse(url);
    let mut out: *mut i8 = if !data.is_null() && !(unsafe { (*data).host }).is_null() {
        strdup(unsafe { (*data).host })
    } else {
        std::ptr::null_mut::<i8>()
    };
    url_free(data);
    return out;
}
#[no_mangle]
pub extern "C" fn url_get_pathname(mut url: *const i8) -> *mut i8 {
    let mut data: *mut url_data_t = url_parse(url);
    let mut out: *mut i8 = if !data.is_null() && !(unsafe { (*data).path }).is_null() {
        strdup(unsafe { (*data).path })
    } else {
        std::ptr::null_mut::<i8>()
    };
    url_free(data);
    return out;
}
#[no_mangle]
pub extern "C" fn url_get_path(mut url: *const i8) -> *mut i8 {
    let mut data: *mut url_data_t = url_parse(url);
    let mut out: *mut i8 = if !data.is_null() && !(unsafe { (*data).path }).is_null() {
        strdup(unsafe { (*data).path })
    } else {
        std::ptr::null_mut::<i8>()
    };
    url_free(data);
    return out;
}
#[no_mangle]
pub extern "C" fn url_get_query_value(mut url: *const url_data_t, mut key: *const i8) -> *const i8 {
    if (unsafe { (*url).query }).is_null() {
        return std::ptr::null::<i8>();
    }
    let mut kv: *const url_key_value = unsafe { (*url).query };
    while !(unsafe { (*kv).key }).is_null() {
        if (unsafe { strcmp((*kv).key, key) }) == 0 {
            return unsafe { (*kv).value };
        }
        kv = unsafe { kv.offset(1) };
    }
    return std::ptr::null::<i8>();
}
#[no_mangle]
pub extern "C" fn url_get_fragment(mut url: *const i8) -> *mut i8 {
    let mut data: *mut url_data_t = url_parse(url);
    let mut out: *mut i8 = if !data.is_null() && !(unsafe { (*data).fragment }).is_null() {
        strdup(unsafe { (*data).fragment })
    } else {
        std::ptr::null_mut::<i8>()
    };
    url_free(data);
    return out;
}
#[no_mangle]
pub extern "C" fn url_get_port(mut url: *const i8) -> *mut i8 {
    let mut data: *mut url_data_t = url_parse(url);
    let mut out: *mut i8 = if !data.is_null() && !(unsafe { (*data).port }).is_null() {
        strdup(unsafe { (*data).port })
    } else {
        std::ptr::null_mut::<i8>()
    };
    url_free(data);
    return out;
}
#[no_mangle]
pub extern "C" fn url_inspect(mut url: *const i8) {
    url_data_inspect(url_parse(url));
}
#[no_mangle]
pub extern "C" fn url_data_inspect(mut data: *const url_data_t) {
    (unsafe { printf(b"#url =>\n\0" as *const u8 as *const i8) });
    if !(unsafe { (*data).protocol }).is_null() {
        (unsafe {
            printf(
                b"    .protocol: \"%s\"\n\0" as *const u8 as *const i8,
                (*data).protocol,
            )
        });
    } else {
        (unsafe { printf(b"    .protocol: (NULL)\n\0" as *const u8 as *const i8) });
    }
    if !(unsafe { (*data).host }).is_null() {
        (unsafe {
            printf(
                b"    .host: \"%s\"\n\0" as *const u8 as *const i8,
                (*data).host,
            )
        });
    } else {
        (unsafe { printf(b"    .host: (NULL)\n\0" as *const u8 as *const i8) });
    }
    if !(unsafe { (*data).userinfo }).is_null() {
        (unsafe {
            printf(
                b"    .userinfo: \"%s\"\n\0" as *const u8 as *const i8,
                (*data).userinfo,
            )
        });
    } else {
        (unsafe { printf(b"    .userinfo: (NULL)\n\0" as *const u8 as *const i8) });
    }
    if !(unsafe { (*data).host }).is_null() {
        (unsafe {
            printf(
                b"    .host: \"%s\"\n\0" as *const u8 as *const i8,
                (*data).host,
            )
        });
    } else {
        (unsafe { printf(b"    .host: (NULL)\n\0" as *const u8 as *const i8) });
    }
    if !(unsafe { (*data).port }).is_null() {
        (unsafe {
            printf(
                b"    .port: \"%s\"\n\0" as *const u8 as *const i8,
                (*data).port,
            )
        });
    } else {
        (unsafe { printf(b"    .port: (NULL)\n\0" as *const u8 as *const i8) });
    }
    if !(unsafe { (*data).path }).is_null() {
        (unsafe {
            printf(
                b"    .path: \"%s\"\n\0" as *const u8 as *const i8,
                (*data).path,
            )
        });
    } else {
        (unsafe { printf(b"    .path: (NULL)\n\0" as *const u8 as *const i8) });
    }
    if !(unsafe { (*data).query }).is_null() {
        let mut nr: u32 = 0 as u32;
        while !(unsafe { (*((*data).query).offset(nr as isize)).key }).is_null() {
            (unsafe {
                printf(
                    b"    .query[%u]: \"%s\" -> \0" as *const u8 as *const i8,
                    nr,
                    (*((*data).query).offset(nr as isize)).key,
                )
            });
            if !(unsafe { (*((*data).query).offset(nr as isize)).value }).is_null() {
                (unsafe {
                    printf(
                        b"\"%s\"\n\0" as *const u8 as *const i8,
                        (*((*data).query).offset(nr as isize)).value,
                    )
                });
            } else {
                (unsafe { printf(b"(NULL)\n\0" as *const u8 as *const i8) });
            }
            nr = nr.wrapping_add(1);
        }
    }
    if !(unsafe { (*data).fragment }).is_null() {
        (unsafe {
            printf(
                b"    .fragment: \"%s\"\n\0" as *const u8 as *const i8,
                (*data).fragment,
            )
        });
    } else {
        (unsafe { printf(b"    .fragment: (NULL)\n\0" as *const u8 as *const i8) });
    };
}
#[no_mangle]
pub extern "C" fn url_free(mut data: *mut url_data_t) {
    if data.is_null() {
        return;
    }
    (unsafe { free((*data).whole_url as *mut ()) });
    (unsafe { free((*data).query as *mut ()) });
    (unsafe { free(data as *mut ()) });
}
